package org.study.apitest;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;

/**
 * @program: mybatis-demo-study
 * @description:
 * @author: tmz
 * @create: 2020-08-21 13:34
 */
public class SqlSessionUtil {
    public static SqlSessionFactory getSqlSessionFactory(){
        InputStream resourceAsStream = null;
        SqlSessionFactory factory = null;
        try {
            resourceAsStream = Resources.getResourceAsStream("mybatis-config.xml");
            factory = new SqlSessionFactoryBuilder().build(resourceAsStream);
        }catch (Exception e ){
            e.printStackTrace();
        }
        return factory;
    }
}
